package com.zwy.Shopping.servlet_;

import com.zwy.Shopping.dao.ProductDao;
import com.zwy.Shopping.dao.impl.ProductDaoImpl;
import com.zwy.Shopping.model.Product;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
@WebServlet("/get_modify_product_by_id")
public class GetModifyProductByIdServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String productIdStr = request.getParameter("productId");
        ProductDao productDao = new ProductDaoImpl();
        int productId = Integer.parseInt(productIdStr);
        Product product = productDao.getProductById(productId);
        request.getSession().setAttribute("modify_product",product);
    }
}
